<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>设置画布阴影</title>
    <link rel="stylesheet" href="../../1-Html/global.css">
    <style>
        #canvas {
            display: block;
            margin: 50px auto;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="400" height="400"></canvas>

    <div class="learn">
        <h1>drawImage函数的使用</h1>
            <ul>
                <li>(img, x, y)</li>
                <li>(img, x, y, w, h)</li>
                <li>(img, sx, sx, sW, sH, dx, dy, dW, dH)</li>
            </ul>
    </div>
</body>
<script>

let canvas = document.getElementById('canvas');
let context = canvas.getContext('2d');          // 得到2d的画笔
let img = new Image();
img.onload = function() {
    context.drawImage(img, 0, 0, 400, 400, 100, 100, 200, 200);
}
img.src = "../../6-Vue/2-Vue-cli/img/2-1-1.png";
</script>
</html>